<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/22
 * Time: 12:50
 */
header('Content-Type:application/json');
include '../classes/logincheck.php';
include '../classes/conn.php';
if(islogin()!='stu_login') {
    die("error");
}
$num=$_SESSION['stu_num'];
$class=$_POST['class'];

$data=array();
//查询姓名
$query="select name,teacher from student where num='{$num}' and class='{$class}'";
$res=mysql_query($query);
$row=mysql_fetch_assoc($res);
$data['name']=$row['name'];
$data['num']=$num;

//查询班级名
$query="select name,teacher from class where num='{$class}'";
$res=mysql_query($query);
$row=mysql_fetch_assoc($res);
$data['class_num']=$class;
$data['class_name']=$row['name'];

//查询教师姓名
$query="select name from teacher where num='{$row['teacher']}'";
$res=mysql_query($query);
$row=mysql_fetch_assoc($res);
$data['teacher']=$row['name'];

$data=json_encode($data);
echo $data;